﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D.B.Data.Common
{
    
   public static class Extensions
    {
        /// <summary>
        /// 扩展字符串转数字
        /// </summary>
        public static int ToInt32(this string? value)
        {
            if(value==null)
                return 0;
            else 
                return Convert.ToInt32(value);

        }


        /// <summary>
        /// 根据身份证计算出身年月日
        /// </summary>
        /// <param name="carId"></param>
        /// <returns></returns>
        public static string GetBirthByCarId (this string carId)
        {
            string result = carId.Substring(6,8);
            return result;  
        }


        public static string GetTime(this DateTime? time)
        {

            if (time.HasValue)
            {
                return time.Value.ToString("yyyy年MM月dd日");
            }
            return string.Empty; // 或者返回默认值，如 "未知日期"
        }
    }
}
